export const shortcutStore = function(state, payload) {
  const nameArr = payload.name.split('.')
  const len = nameArr.length

  if (len >= 2) {
    let obj = state[nameArr[0]]
    for (let i = 1; i < len - 1; i++) {
      obj = obj[nameArr[i]]
    }
    obj[nameArr[len - 1]] = payload.value
  } else {
    state[payload.name] = payload.value
  }
}

export const shortcutUpdateState = function({
  commit
}, {
  name,
  value
}) {
  commit('shortcutStore', {
    name,
    value
  })
}
